<?php
class Sabai_Template_Default_Helper_XiggBreadCrumbForNode extends Sabai_Template_Default_Helper
{
    function execute(&$node, &$config, $linkSelf = true)
    {
        if (SABAI_URL_DIR != $homepage_url = $config->get('homepageURL')) {
            $html[] = sprintf('<a href="%s">%s</a>', $homepage_url, h(_('Home')));
        }
        $html[] = sprintf('<a href="%s">%s</a>', Sabai_URL::get(), h($config->get('toppageTitle')));
        if ($category =& $node->get('Category')) {
            $parents =& $category->parents();
            while ($parent_category =& $parents->getNext()) {
                $html[] = sprintf('<a href="%s">%s</a>', Sabai_URL::get('/', array('category_id' => $parent_category->getId())), h($parent_category->getLabel()));
            }
            $html[] = sprintf('<a href="%s">%s</a>', Sabai_URL::get('/', array('category_id' => $category->getId())), h($category->getLabel()));
        }
        if ($linkSelf) {
            $html[] = sprintf('<a href="%s">%s</a> &#8250; ', Sabai_URL::get('/node/' . $node->getId()), h(Sabai_I18N::strcutMore($node->getLabel(), 50)));
        } else {
            $html[] = h(Sabai_I18N::strcutMore($node->getLabel(), 50));
        }
        return implode(' &#8250; ', $html);
    }
}